#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <list>
#include <algorithm>
using namespace std;

static char arr[101][101];

static void Foo(int field, int N, int M) {
    printf("Field #%d:\n", field);

    for (int i = 0; i < N; ++i)
        scanf("%s", arr[i]);

    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < M; ++j) {
            const char ch = arr[i][j];
            if (ch != '*') {
                int cnt = 0;
                if (i > 0 && j > 0 && arr[i-1][j-1] == '*')
                    ++cnt;
                if (i > 0 && arr[i-1][j] == '*')
                    ++cnt;
                if (i > 0 && j < (M-1) && arr[i-1][j+1] == '*')
                    ++cnt;
                if (j > 0 && arr[i][j-1] == '*')
                    ++cnt;
                if (j < (M-1) && arr[i][j+1] == '*')
                    ++cnt;
                if (i < (N-1) && j > 0 && arr[i+1][j-1] == '*')
                    ++cnt;
                if (i < (N-1) && arr[i+1][j] == '*')
                    ++cnt;
                if (i < (N-1) && j < (M-1) && arr[i+1][j+1] == '*')
                    ++cnt;
                //arr[i][j] = '0' + cnt;
                printf("%d", cnt);
            } else
                printf("%c", ch);
        }
        printf("\n");
    }
}

int main() {
    int N = 0, M = 0;
    scanf("%d %d", &N, &M);
    if (N == 0 && M == 0)
        return 0;
    Foo(1, N, M);

    for (int field = 2;; ++field) {
        scanf("%d %d", &N, &M);
        if (N == 0 && M == 0)
            break;
        
        printf("\n");
        Foo(field, N, M);
    }
    return 0;
}
